package com.sdrongyou.tms.controller;


import com.alibaba.fastjson2.JSONObject;
import com.sdrongyou.tms.dto.DriverDO;
import com.sdrongyou.tms.dto.DriverVO;
import com.sdrongyou.tms.service.DriverIService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 司机管理Controller
 */
@RestController
@RequestMapping(value = "/api/tms/driver")
public class DriverController {

    @Resource
    private DriverIService driverIService;

    /**
     * 分页查询
     */
    @RequestMapping(value = "/queryDriverPageList", method = RequestMethod.GET)
    public List<DriverVO> queryDriverPageList(DriverDO driverDO) {
        return driverIService.queryDriverPageList(driverDO);
    }

    /**
     * 创建司机信息
     */
    @RequestMapping(value = "/saveDriver", method = RequestMethod.POST)
    public JSONObject saveDriver(@RequestBody DriverDO driverDO) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", driverIService.saveDriver(driverDO));
        return jsonObject;
    }

    /**
     * 更新司机信息
     */
    @RequestMapping(value = "/updateDriver", method = RequestMethod.POST)
    public JSONObject updateDriver(@RequestBody DriverDO driverDO) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", driverIService.updateDriver(driverDO));
        return jsonObject;
    }

    /**
     * 删除司机
     */
    @DeleteMapping(value = "/deleteDriver")
    public JSONObject deleteDriver(Long id) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", driverIService.deleteDriver(id));
        return jsonObject;
    }

    /**
     * 批量删除司机
     */
    @PostMapping(value = "/batchDeleteDriver")
    public JSONObject batchDeleteDriver(@RequestBody List<Long> ids) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", driverIService.batchDeleteDriver(ids));
        return jsonObject;
    }

    /**
     * 查询司机明细信息
     */
    @RequestMapping(value = "/queryDriverById", method = RequestMethod.GET)
    public DriverVO queryDriverById(Long id) {
        return driverIService.queryDriverById(id);
    }

    /**
     * 查询所有司机列表
     */
    @RequestMapping(value = "/queryDriverDataList", method = RequestMethod.GET)
    public List<DriverVO> queryDriverDataList(DriverDO driverDO) {
        return driverIService.queryDriverDataList(driverDO);
    }

}
